package com.stylefeng.guns.core.util;

import com.stylefeng.guns.core.common.constant.Const;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.modular.system.model.Dept;
import com.stylefeng.guns.modular.system.service.IDeptService;

import java.util.List;


/**
 * 获取字典信息
 */
public class DeptUtil {

    IDeptService iDeptService =SpringContextHolder.getBean(IDeptService.class);

    /**
     * 根据字典code和字典中的值获取对应的名称
     */
    public String getPlatformById() {
        StringBuffer html = new StringBuffer();
        html.append("<option value='"+ ShiroKit.getUser().getDeptcode()+"' selected=\"true\" >"+ShiroKit.getUser().getDeptName()+"</option>\r\n");
        //组装查询

        if(ShiroKit.getUser().getDeptcode().equals(Const.DEFAULT_PH)){
            List<Dept> depts = iDeptService.selectList(null);
            for (Dept item : depts) {
                if(!item.getCode().equals(Const.DEFAULT_PH))
                html.append("<option value=\"" + item.getCode() + "\">" + item.getFullname() + "</option>\r\n");
            }
        }

        return html.toString();
    }
}
